package main

import (
	"fmt"
	"io/ioutil"
	"strconv"
)

func convertToBin (n int) string {
	result := ""
	for ; n > 0; n /= 2 {
		lsb := n % 2
		result = strconv.Itoa(lsb) + result
	}
	return result
}

func main() {
	const filename = "abc.txt"
	contents, err := ioutil.ReadFile(filename)
	if err != nil {
		fmt.Println(err)
	} else {
		fmt.Printf("%s\n", contents)
	}
// if else 是一个块级作用域 if 不需要括号
	if content, erro := ioutil.ReadFile(filename); erro != nil {
		fmt.Println(erro)
	} else {
		fmt.Printf("%s\n", content)
	}

	fmt.Println(
		convertToBin(5),
		convertToBin(7),
		convertToBin(13),
	)
}
